using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using RBAC.Domain.Repositories;
using RBAC.Infrastructure.Data;

namespace RBAC.Infrastructure;

public static class ServiceCollectionExtension
{
    public static IServiceCollection AddServiceCollectionExtension(this IServiceCollection services, IConfiguration configuration)
    {
        var con = configuration.GetConnectionString("mysql");
        services.AddDbContext<ApplicationDbContext>(options =>
         options.UseMySql(con, ServerVersion.AutoDetect(con)));
        services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
        return services;
    }
}